const deflateWidth = 1920;
const deflateHeight = 1080;

function pxVw(size) {
  return `${(size * 100) / deflateWidth}vw`;
}

function pxVh(size) {
  return `${(size * 100) / deflateHeight}vh`;
}

function pxFont(size) {
  return `${(size * 100) / deflateWidth}vw`;
}

function pxChartVw(size) {
  const clientWidth =
    window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  if (!clientWidth) {
    return size / 2;
  }
  const scale = clientWidth / deflateWidth;
  return Number(((size / 2) * scale).toFixed(3));
}

function pxChartVh(size) {
  const clientHeight =
    window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  if (!clientHeight) {
    return size / 2;
  }
  const scale = clientHeight / deflateHeight;
  return Number(((size / 2) * scale).toFixed(3));
}

function pxChartFont(size) {
  const clientWidth =
    window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
  if (!clientWidth) {
    return size / 2;
  }
  const scale = clientWidth / deflateWidth;
  return Number(((size / 2) * scale).toFixed(3));
}

// 确保导出所有需要的函数
export {
  pxVw,
  pxVh,
  pxFont,
  pxChartVw,
  pxChartVh,
  pxChartFont
};